package com.heima.aliyun;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.6.0</version>
</dependency>
*/

public class ScanText {
    public static void main(String[] args) {

        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI5tR3EmHGjr9q5oyD9gLg", "2iwCINZoqeoHNdhawj81XMbbrgb9jh");
        /** use STS Token
        DefaultProfile profile = DefaultProfile.getProfile(
            "<your-region-id>",           // The region ID
            "<your-access-key-id>",       // The AccessKey ID of the RAM account
            "<your-access-key-secret>",   // The AccessKey Secret of the RAM account
            "<your-sts-token>");          // STS Token
        **/

        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();



        request.setSysMethod(MethodType.POST);
        request.setSysDomain("imageaudit.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2019-12-30");
        request.setSysAction("ScanText");
        request.putQueryParameter("Tasks.1.Content", "我是好人");

        request.putQueryParameter("Labels.1.Label", "spam");
        request.putQueryParameter("Labels.2.Label", "politics");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}